<template>
	<view>
		<mh-navbar  :back="true" title="物流信息" custom fixed center zIndex="1010" />
		<view class="container">
			<view class="logistics-info-container">
				<image :src="logisticsList.logo" style="width: 32px;height: 32px;border-radius: 25px;"></image>
				<view class="logistics-info">
					{{logisticsList.expName}} {{logisticsList.number}}
				</view>
				<view class="logistics-info-copy" @click="onCopy(logisticsList.number)">	
					<text>复制</text>
				</view>
			</view>
			<u-time-line>
				<u-time-line-item v-for="(item,index) in logisticsList.list" :key='index'>
					<template v-slot:content>
						<view>
							<view class="u-order-desc">{{item.status}}</view>
							<view class="u-order-time">{{item.time}}</view>
						</view>
					</template>
				</u-time-line-item>
			</u-time-line>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				logisticsList:{},
				orderId:'',
			}
		},
		onLoad(e){
			this.orderId = e.orderId;
			this.getLogisticsList();
		},
		methods: {
			getLogisticsList(){
				this.$u.api.logistics({orderId:this.orderId}).then(res => {
					debugger
					if (res.code == 200){
						this.logisticsList = res.data;
					}
				});
			},
			onCopy(number){
				console.info('点击复制')
				// #ifdef APP-PLUS
					uni.setClipboardData({
						data: number,
						success: function () {
							console.log('success');
							uni.showModal({
								title: '复制成功',
								content: '订单已复制到粘贴板', 
								showCancel:false,
								success: function(res) {
									if (res.confirm) {											 
										//console.log('用户点击确定');
									} else if (res.cancel) {
										//console.log('用户点击取消');
									}
								}
							});
						}
					});
				// #endif
				
				
				// #ifdef H5
				this.$utils.handleClipboard(number, event, () => {
						uni.showToast({
							icon: 'none',
							title: '订单已复制到粘贴板。'
						})
					  }, () => {
						uni.showToast({
							icon: 'none',
							title: '复制失败'
						})
				})
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #FFFFFF;
	}
	.container{
		padding: 20px;
		.logistics-info-container{
			display: flex;
			align-items: center;
			height: 40px;
			.logistics-info{
				margin-left: 5px;
				display: flex;
				align-content: center;
				align-items: center;
			}
			.logistics-info-copy{
				margin-left: 10px;
				text{
					color: #b5b0b0
				}
			}
		}
	}
	.u-node {
		width: 44rpx;
		height: 44rpx;
		border-radius: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #d0d0d0;
	}
	
	.u-order-title {
		color: #333333;
		font-weight: bold;
		font-size: 32rpx;
	}
	
	.u-order-desc {
		color: rgb(150, 150, 150);
		font-size: 28rpx;
		margin-bottom: 6rpx;
	}
	
	.u-order-time {
		color: rgb(200, 200, 200);
		font-size: 26rpx;
	}
</style>
